package com.leyou.search.dto;

import java.util.Map;

/**
 * @author HeGuanChao
 * @Description TODO
 * @Date 2020/4/7 17:28
 */
public class SearchRequest {
    /**
     * 搜索条件
     */
    private String key;
    /**
     * 当前页
     */
    private Integer page;
    /**
     * 选中的过滤项
     */
    private Map<String,Object> filters;
    /**
     * 每页大小
     */
    public static final Integer DEFAULT_SIZE = 20;
    /**
     * 默认页
     */
    public static final Integer DEFAULT_PAGE = 1;

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public Integer getPage() {
        if (page == null) {
            return DEFAULT_PAGE;
        }
        // 页码不能小于1
        return Math.max(DEFAULT_PAGE, page);
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Integer getSize() {
        return DEFAULT_SIZE;
    }

    public Map<String, Object> getFilters() {
        return filters;
    }

    public void setFilters(Map<String, Object> filters) {
        this.filters = filters;
    }
}
